<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cetak Fee Baby Kc</title>
<?php $this->load->helper('HTML');
echo link_tag('css/style2.css');
echo link_tag('images/favicon.ico','shortcut icon','image/x-icon');
?>
</head>
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=baby_kc.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<body>
<table width="800" align="center" class="detail">
	<tr class="detail2">
   	  <td align="center">
        <table width="800" align="center" class="detail">
        <tr class="detail2">
          <td width="440" rowspan="4" valign="top"><img src="<?php echo base_url();?>images/logo.jpg" />&nbsp;</td>
          <td width="41"><a href="javascript:window.print()" onclick="location.href='laporan/fee';"><img src="<?php echo base_url();?>/images/print.jpg"/></a></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td width="41">&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" align="center">LAPORAN FEE BABY KC <?php echo $nama_unit?></td>
                <td>&nbsp;</td>
        </tr>
        <tr >
            <td colspan="2"class="detail2" align="center">PERIODE : <?php echo strtoupper($nama_bulan). " " . date('Y') ?></td>
                <td>&nbsp;</td>
        </tr>

    </table>    </td>
    <tr>
    	<td align="center">
        	<table width="800" border="1" align="center"  class="detail">
			<tr class="detail2">
                	<th width="61" rowspan="4">STATUS</th>
                    <th width="37" rowspan="4">DIST</th>
                    <th width="79" rowspan="4">KET</th>
			</tr>
            <tr class="detail2">
            	<td colspan="6">&nbsp;</td>
                <th width="95" rowspan="3">HARGA NETTO</th>
                <th width="89" rowspan="3">HARGA <br />DEALER</th>
                <th width="56" rowspan="3">BONUS</th>
                <th width="59" rowspan="3">PPH 5%</th>
                <th width="76" rowspan="3">JUMLAH</th>
            </tr>

                <tr>
                	<th colspan="3">GROUP 20%</th>
                    <th colspan="3">GROUP 10%</th>
                </tr>

                <tr>
                	<td colspan="3">&nbsp;</td>
                    <td colspan="3">&nbsp;</td>
                </tr>
                <?php
				$regD = 0;
				$hutD = 0;
				$har_hut = 0;
				$har_reg = 0;
				$reg_total = 0;
				$hut_total = 0;
				$regT10=0;
				$regT20=0;
				$regM10=0;
				$regTC10=0;
				
				$hutT20=0;
				$hutM20=0;
				$hutTC20=0;
				
				$hutT10=0;
				$hutM10=0;
				$hutTC10=0;
				
				$calT20=0;
				$calM20=0;
				$calTC20=0;
				
				$calT10=0;
				$calM10=0;
				$calTC10=0;
				
				$tinT20=0;
				$tinM20=0;
				$tinTC20=0;
				
				$tinT10=0;
				$tinM10=0;
				$tinTC10=0;
				
				$ifiT20=0;
				$ifiM20=0;
				$ifiTC20=0;
				
				$ifiT10=0;
				$ifiM10=0;
				$ifiTC10=0;
				
				$ifoT20=0;
				$ifoM20=0;
				$ifoTC20=0;
				
				$ifoT10=0;
				$ifoM10=0;
				$ifoTC10=0;
				
				$netT20=0;
				$netM20=0;
				$netTC20=0;
				
				$netT10=0;
				$netM10=0;
				$netTC10=0;
								
				$omsettulipreg20=0;
				$omsettulipreg10=0;
				$omsetdealerreg=0;
				foreach ($RegTulip as $row):
					     $omsettulipreg20= $omsettulipreg20 + $row->TGroup20;
						 $omsettulipreg10= $omsettulipreg10 + $row->TGroup10;
				endforeach;	
				foreach ($RegDealer as $row1):
					     $omsetdealerreg= $omsetdealerreg + $row1->RegDealer;
				endforeach;	 
				?>
                <tr>
                	<td><?php echo $data_cabang_kepala->strkepala_cabang?></td>
                    <td><?php echo 'PIMPINAN';?></td>
                    <td>Reguler</td>
					<td colspan="3" align="center"><?php echo (empty($omsettulipreg20))?'-':number_format($omsettulipreg20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipreg10))?'-':number_format($omsettulipreg10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerreg))?'-':number_format($omsetdealerreg)?></td>
                    <td align="center"><?php echo (empty($omsetdealerreg))?'-':number_format(($omsetdealerreg) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerreg))?'-':number_format(($omsetdealerreg * 1/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($omsetdealerreg)){
						$regD = $omsetdealerreg;
						$har_reg =  (($omsetdealerreg) * 1/100) - (($omsetdealerreg* 1/100) * 5/100);
					
						echo (empty($har_reg))?'-':number_format($har_reg);
					}
					
					?></td>
                </tr>
                <?php 
				$omsettuliphut20=0;
				$omsettuliphut10=0;
				$omsetdealerhut=0;
				foreach ($HutTulip as $row2):
					     $omsettuliphut20= $omsettuliphut20 + $row2->TGroup20;
						 $omsettuliphut10= $omsettuliphut10 + $row2->TGroup10;
				endforeach;	
				foreach ($HutDealer as $row3):
					     $omsetdealerhut= $omsetdealerhut + $row3->HutDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Hut</td>
                    <td colspan="3" align="center"><?php echo (empty($omsettuliphut20))?'-':number_format($omsettuliphut20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettuliphut10))?'-':number_format($omsettuliphut10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerhut))?'-':number_format($omsetdealerhut)?></td>
                    <td align="center"><?php echo (empty($omsetdealerhut))?'-':number_format(($omsetdealerhut) * 1/100); $fhut=($omsetdealerhut * 1)/100?></td>
                    <td align="center"><?php echo (empty($omsetdealerhut))?'-':number_format(($fhut*5)/100);?></td>
                    <td align="center"><?php 
					
					if(!empty($omsetdealerhut)){
						$hutD = $omsetdealerhut;
						$har_hut = (($omsetdealerhut) * 1/100) - (($omsetdealerhut* 1/100) * 5/100);
						echo (empty($har_hut))?'-':number_format($har_hut);
					}
					?></td>
                </tr>
                <?php 
				$omsettulipcal20=0;
				$omsettulipcal10=0;
				$omsetdealercal=0;
				foreach ($CalTulip as $row4):
					     $omsettulipcal20= $omsettulipcal20 + $row4->TGroup20;
						 $omsettulipcal10= $omsettulipcal10 + $row4->TGroup10;
				endforeach;	
				foreach ($CalDealer as $row5):
					     $omsetdealercal= $omsetdealercal + $row5->CalDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Challenge</td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipcal20))?'-':number_format($omsettulipcal20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipcal10))?'-':number_format($omsettulipcal10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealercal))?'-':number_format($omsetdealercal)?></td>
                    <td align="center"><?php echo (empty($omsetdealercal))?'-':number_format(($omsetdealercal) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealercal))?'-':number_format(($omsetdealercal * 1/100)*5/100)?></td>
                    <td align="center"><?php 
					$calD=0;
					$har_cal=0;
					if(!empty($omsetdealercal)){
						$calD = $omsetdealercal;
						$har_cal = (($omsetdealercal) * 1/100) + (($omsetdealercal* 1/100) * 5/100);
						echo (empty($har_cal))?'-':number_format($har_cal);
					}
					?></td>
                </tr>
                <?php 
				$omsettuliptin20=0;
				$omsettuliptin10=0;
				$omsetdealertin=0;
				foreach ($tinTulip as $row6):
					     $omsettuliptin20= $omsettuliptin20 + $row6->TGroup20;
						 $omsettuliptin10= $omsettuliptin10 + $row6->TGroup10;
				endforeach;	
				foreach ($tinDealer as $row7):
					     $omsetdealertin= $omsetdealertin + $row7->tinDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Trade In</td>
                    <td colspan="3" align="center"><?php echo (empty($omsettuliptin20))?'-':number_format($omsettuliptin20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettuliptin10))?'-':number_format($omsettuliptin10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealertin))?'-':number_format($omsetdealertin)?></td>
                    <td align="center"><?php echo (empty($omsetdealertin))?'-':number_format(($omsetdealertin) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealertin))?'-':number_format(($omsetdealertin * 1/100)*5/100)?></td>
                    <td align="center"><?php 
					$tinD=0;
					$har_tin=0;
					if(!empty($omsetdealertin)){
						$tinD = $omsetdealertin;
						$har_tin = (($omsetdealertin) * 1/100) + (($omsetdealertin* 1/100) * 5/100);
						echo (empty($har_tin))?'-':number_format($har_tin);
					}
					?></td>
                </tr>
                <?php 
				$omsettulipifi=0;
				$omsetdealerifi=0;
				foreach ($ifiTulip as $row8):
					     $omsettulipifi= $omsettulipifi + $row8->OmsetTulip;
				endforeach;	
				foreach ($ifiDealer as $row9):
					     $omsetdealerifi= $omsetdealerifi + $row9->ifiDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>1 Free 1 Hut</td>
                    <td colspan="3" align="center">&nbsp;</td>
                  <td colspan="3" align="center">&nbsp;</td>
                  <td align="center"><?php echo (empty($omsettulipifi))?'-':number_format($omsettulipifi)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifi))?'-':number_format($omsetdealerifi)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifi))?'-':number_format(($omsetdealerifi) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifi))?'-':number_format(($omsetdealerifi * 1/100)*5/100)?></td>
                    <td align="center"><?php 
					$ifiD=0;
					$har_ifi=0;
					if(!empty($omsetdealerifi)){
						$ifiD = $omsetdealerifi;
						$har_ifi = (($omsetdealerifi) * 1/100) + (($omsetdealerifi* 1/100) * 5/100);
						echo (empty($har_ifi))?'-':number_format($har_ifi);
					}
					?></td>
                </tr>
                 <?php 
				$omsettulipifo20=0;
				$omsettulipifo10=0;
				$omsetdealerifo=0;
				foreach ($ifoTulip as $row10):
					     $omsettulipifo20= $omsettulipifo20 + $row10->TGroup20;
						 $omsettulipifo10= $omsettulipifo10 + $row10->TGroup10;
				endforeach;	
				foreach ($ifoDealer as $row11):
					     $omsetdealerifo= $omsetdealerifo + $row11->ifoDealer;
				endforeach;	 
				?>
                 <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>1 Free 1 </td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipifo20))?'-':number_format($omsettulipifo20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipifo10))?'-':number_format($omsettulipifo10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerifo))?'-':number_format($omsetdealerifo)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifo))?'-':number_format(($omsetdealerifo) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifo))?'-':number_format(($omsetdealerifo * 1/100)*5/100)?></td>
                    <td align="center"><?php 
					$ifoD=0;
					$har_ifo=0;
					if(!empty($omsetdealerifo)){
						$ifoD = $omsetdealerifo;
						$har_ifo = (($omsetdealerifo) * 1/100) + (($omsetdealerifo* 1/100) * 5/100);
						echo (empty($har_ifo))?'-':number_format($har_ifo);
					}
					?></td>
                </tr>
                <?php 
				$omsettulipnet20=0;
				$omsettulipnet10=0;
				$omsetdealernet=0;
				foreach ($netTulip as $row12):
					     $omsettulipnet20= $omsettulipnet20 + $row12->TGroup20;
						 $omsettulipnet10= $omsettulipnet10 + $row12->TGroup10;
				endforeach;	
				foreach ($netDealer as $row13):
					     $omsetdealernet= $omsetdealernet + $row13->netDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Netto</td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipnet20))?'-':number_format($omsettulipnet20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipnet10))?'-':number_format($omsettulipnet10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealernet))?'-':number_format($omsetdealernet)?></td>
                    <td align="center"><?php echo (empty($omsetdealernet))?'-':number_format(($omsetdealernet) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealernet))?'-':number_format(($omsetdealernet * 1/100)*5/100)?></td>
                    <td align="center"><?php 
					$netD=0;
					$har_net=0;
					if(!empty($omsetdealernet)){
						$netD = $omsetdealernet;
						$har_net = (($omsetdealernet) * 1/100) + (($omsetdealernet* 1/100) * 5/100);
						echo (empty($har_net))?'-':number_format($har_net);
					}
					?></td>
                </tr>   
                <?php 
				$RB20=0;
				$CB20=0;
				$TB20=0;
				$FH20=0;
				$IF20=0;
				$NB20=0;
				$HB20=0;
				$HB10=0;
				
				$RB10=0;
				$CB10=0;
				$TB10=0;
				$FH10=0;
				$IF10=0;
				$NB10=0;
				
				$BregD=0;
				$BhutD=0;
				$BcalD=0;
				$BtinD=0;
				$BifiD=0;
				$BifoD=0;
				$BnetD=0;
				
				$har_Breg=0;
				$har_Bhut=0;
				$har_Bcal=0;
				$har_Btin=0;
				$har_Bifi=0;
				$har_Bifo=0;
				$har_Bnet=0;
				
				$BnsregD=0;
				$BnshutD=0;
				$BnscalD=0;
				$BnstinD=0;
				$BnsifiD=0;
				$BnsifoD=0;
				$BnsnetD=0;
				
				$pphregD=0;
				$pphhutD=0;
				$pphcalD=0;
				$pphtinD=0;
				$pphifiD=0;
				$pphifoD=0;
				$pphnetD=0;

			foreach($data_cabang as $cab):
			//reguler
            $BRegTulip = $this->Penjualan_model->get_reguler_tulip($cab->intid_cabang, $bulan);
            $BRegDealer = $this->Penjualan_model->get_reguler_dealer($cab->intid_cabang, $bulan);
            //Hut
            $BHutTulip = $this->Penjualan_model->get_hut_tulip($cab->intid_cabang, $bulan);
            $BHutDealer = $this->Penjualan_model->get_hut_dealer($cab->intid_cabang, $bulan);
			//Challenge
            $BCalTulip = $this->Penjualan_model->get_cal_tulip($cab->intid_cabang, $bulan);
            $BCalDealer = $this->Penjualan_model->get_cal_dealer($cab->intid_cabang, $bulan);
			
			//Trade In
            $BtinTulip = $this->Penjualan_model->get_tin_tulip($cab->intid_cabang, $bulan);
            $BtinDealer = $this->Penjualan_model->get_tin_dealer($cab->intid_cabang, $bulan);
			
			//1 Free 1 Hut
            $BifiTulip = $this->Penjualan_model->get_ifi_tulip($cab->intid_cabang, $bulan);
            $BifiDealer = $this->Penjualan_model->get_ifi_dealer($cab->intid_cabang, $bulan);
			
			//1 Free 1 
            $BifoTulip = $this->Penjualan_model->get_ifo_tulip($cab->intid_cabang, $bulan);
            $BifoDealer = $this->Penjualan_model->get_ifo_dealer($cab->intid_cabang, $bulan);

			//Netto 
            $BnetTulip = $this->Penjualan_model->get_net_tulip($cab->intid_cabang, $bulan);
            $BnetDealer = $this->Penjualan_model->get_net_dealer($cab->intid_cabang, $bulan);

			$omsettulipbreg20=0;
			$omsettulipbreg10=0;
			$omsetdealerbreg=0;
			foreach ($BRegTulip as $row14):
				     $omsettulipbreg20= $omsettulipbreg20 + $row14->TGroup20;
					 $omsettulipbreg10= $omsettulipbreg10 + $row14->TGroup10;
			endforeach;	
			foreach ($BRegDealer as $row15):
				     $omsetdealerbreg= $omsetdealerbreg + $row15->RegDealer;
			endforeach;	 
			?>
                <tr>
                	<td><?php echo 'Baby Kc';?></td>
                    <td><?php echo $cab->strnama_cabang?></td>
                    <td>Reguler</td>
					
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbreg20))?'-':number_format($omsettulipbreg20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbreg10))?'-':number_format($omsettulipbreg10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerbreg))?'-':number_format($omsetdealerbreg)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbreg))?'-':number_format(($omsetdealerbreg) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbreg))?'-':number_format(($omsetdealerbreg * 1/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($omsetdealerbreg)){
						$RB20=$RB20 + $omsettulipbreg20;
						$RB10=$RB10 + $omsettulipbreg10;
						$BregD = $omsetdealerbreg;
						$BnsregD = $BnsregD + $omsetdealerbreg * 1/100 ;
						$pphregD = $pphregD + ($omsetdealerbreg * 1/100) * 5/100;
					    $har_Breg = $har_Breg + (($omsetdealerbreg) * 1/100) - (($omsetdealerbreg* 1/100) * 5/100);
					
						echo (empty($har_Breg))?'-':number_format($har_Breg);
					}
					
					?></td>
                </tr>
                <?php 
				$omsettulipbhut20=0;
				$omsettulipbhut10=0;
				$omsetdealerbhut=0;
				foreach ($BHutTulip  as $row16):
					     $omsettulipbhut20= $omsettulipbhut20 + $row16->TGroup20;
						 $omsettulipbhut10= $omsettulipbhut10 + $row16->TGroup10;
				endforeach;	
				foreach ($BHutDealer  as $row17):
					     $omsetdealerbhut= $omsetdealerbhut + $row17->HutDealer;
				endforeach;	 
				?>
              	<tr>
                  <td>&nbsp;</td>
              	  <td>&nbsp;</td>
              	  <td>Hut</td>
              	  <td colspan="3" align="center"><?php echo (empty($omsettulipbhut20))?'-':number_format($omsettulipbhut20)?></td>
              	  <td colspan="3" align="center"><?php echo (empty($omsettulipbhut10))?'-':number_format($omsettulipbhut10)?></td>
              	  <td align="center">&nbsp;</td>
              	  <td align="center"><?php echo (empty($omsetdealerbhut))?'-':number_format($omsetdealerbhut)?></td>
              	  <td align="center"><?php echo (empty($omsetdealerbhut))?'-':number_format(($omsetdealerbhut) * 1/100); $fhut=($omsetdealerbhut * 1)/100?></td>
              	  <td align="center"><?php echo (empty($omsetdealerbhut))?'-':number_format(($fhut*5)/100);?></td>
              	  <td align="center"><?php 
					
					if(!empty($omsetdealerbhut)){
						$HB20 = $HB20 + $omsettulipbhut20;
						$HB10 = $HB10 + $omsettulipbhut10;
						
						$BhutD = $omsetdealerbhut;
						$BnshutD = $BnshutD + $omsetdealerbhut * 1 / 100;
						$pphutD = $pphhutD + ($omsetdealerbhut * 1/100) * 5/100;
						$har_Bhut = $har_Bhut + (($omsetdealerbhut) * 1/100) - (($omsetdealerbhut* 1/100) * 5/100);
					
						echo (empty($har_Bhut))?'-':number_format($har_Bhut);
					}
					?></td>
           	  </tr>
              	<?php 
				$omsettulipbcal20=0;
				$omsettulipbcal10=0;
				$omsetdealerbcal=0;
				foreach ($BCalTulip  as $row18):
					     $omsettulipbcal20= $omsettulipbcal20 + $row18->TGroup20;
						 $omsettulipbcal10= $omsettulipbcal10 + $row18->TGroup10;
				endforeach;	
				foreach ($BCalDealer  as $row19):
					     $omsetdealerbcal= $omsetdealerbcal + $row19->CalDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Challenge</td>
					
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbcal20))?'-':number_format($omsettulipbcal20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbcal10))?'-':number_format($omsettulipbcal10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerbcal))?'-':number_format($omsetdealerbcal)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbcal))?'-':number_format(($omsetdealerbcal) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbcal))?'-':number_format(($omsetdealerbcal * 1/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($omsetdealerbcal)){
						$CB20 = $CB20 + $omsettulipbcal20;
						$CB10 = $CB10 + $omsettulipbcal10;
						
						$BcalD = $omsetdealerbcal;
						$BnscalD = $BnscalD + $omsetdealerbcal * 1 / 100;
						$pphcalD = $pphcalD + ($omsetdealerbcal * 1/100) * 5/100;
						$har_Bcal = $har_Bcal + (($omsetdealerbcal) * 1/100) + (($omsetdealerbcal* 1/100) * 5/100);
					
						echo (empty($har_Bcal))?'-':number_format($har_Bcal);
					}
					
					?></td>
                </tr>
                <?php 
				$omsettulipbtin20=0;
				$omsettulipbtin10=0;
				$omsetdealerbtin=0;
				foreach ($BtinTulip as $row20):
					     $omsettulipbtin20= $omsettulipbtin20 + $row20->TGroup20;
						 $omsettulipbtin10= $omsettulipbtin10 + $row20->TGroup10;
				endforeach;	
				foreach ($BtinDealer as $row21):
					     $omsetdealerbtin= $omsetdealerbtin + $row21->tinDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Trade In</td>
					
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbtin20))?'-':number_format($omsettulipbtin20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbtin10))?'-':number_format($omsettulipbtin10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerbtin))?'-':number_format($omsetdealerbtin)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbtin))?'-':number_format(($omsetdealerbtin) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbtin))?'-':number_format(($omsetdealerbtin * 1/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($BtinDealer->BtinDealer)){
						$TB20 = $TB20 + $Bomsettulipbtin20;
						$TB10 = $TB10 + $omsettulipbtin10;
						
						$BtinD = $omsetdealerbtin;
						$BnstinD = $BnstinD + $omsetdealerbtin * 1 / 100;
						$pphtinD = $pphtinD + ($omsetdealerbtin * 1/100) * 5/100;
						$har_Btin = $har_Btin + (($omsetdealerbtin) * 1/100) + (($omsetdealerbtin* 1/100) * 5/100);
						echo (empty($har_Btin))?'-':number_format($har_Btin);
					}
					
					?></td>
                </tr>
                <?php 
				$omsettulipbifi=0;
				$omsetdealerbifi=0;
				foreach ($BifiTulip as $row22):
					     $omsettulipbifi= $omsettulipbifi + $row22->OmsetTulip;
				endforeach;	
				foreach ($BifiDealer as $row23):
					     $omsetdealerbifi= $omsetdealerbifi + $row23->ifiDealer;
				endforeach;	 
				?> 
                 <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>1 Free 1 Hut</td>
					
                    <td colspan="3" align="center">&nbsp;</td>
                   <td colspan="3" align="center">&nbsp;</td>
                   <td align="center"><?php echo (empty($omsettulipbifi))?'-':number_format($omsettulipbifi)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbifi))?'-':number_format($omsetdealerbifi)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbifi))?'-':number_format(($omsetdealerbifi) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbifi))?'-':number_format(($omsetdealerbifi * 1/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($omsetdealerbifi)){
						$FH20 = $FH20 + $omsettulipbifi20;
						$FH10 = $FH10 + $omsettulipbifi10;
						
						$BifiD = $omsetdealerbifi;
						$pphifiD = $pphifiD + ($omsetdealerbifi * 1/100) * 5/100;
						$BnsifiD = $BnsifiD + $omsetdealerbifi * 1 / 100;
						$har_Bifi = $har_Bifi + (($omsetdealerbifi) * 1/100) + (($omsetdealerbifi* 1/100) * 5/100);
					
						echo (empty($har_Bifi))?'-':number_format($har_Bifi);
					}
					
					?></td>
                </tr>
                 <?php 
				$omsettulipbifo20=0;
				$omsettulipbifo10=0;
				$omsetdealerbifo=0;
				foreach ($BifoTulip as $row24):
					     $omsettulipbifo20= $omsettulipbifo20 + $row24->TGroup20;
						 $omsettulipbifo10= $omsettulipbifo10 + $row24->TGroup10;
				endforeach;	
				foreach ($BifoDealer as $row25):
					     $omsetdealerbifo= $omsetdealerbifo + $row25->ifoDealer;
				endforeach;	 
				?>
                 <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>1 Free 1 </td>
					
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbifo20))?'-':number_format($omsettulipbifo20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbifo10))?'-':number_format($omsettulipbifo10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerbifo))?'-':number_format($omsetdealerbifo)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbifo))?'-':number_format(($omsetdealerbifo) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbifo))?'-':number_format(($omsetdealerbifo * 1/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($omsetdealerbifo)){
						$IF20 = $IF20 + $omsettulipbifo20;
						$IF10 = $IF10 + $omsettulipbifo10;
						
						$BifoD = $omsetdealerbifo;
						$pphifoD = $pphifoD + ($omsetdealerbifo * 1/100) * 5/100;
						$BnsifoD = $BnsifoD + $omsetdealerbifo * 1 / 100;
						
						$har_Bifo = $har_Bifo + (($omsetdealerbifo) * 1/100) + (($omsetdealerbifo* 1/100) * 5/100);
					
						echo (empty($har_Bifo))?'-':number_format($har_Bifo);
					}
					
					?></td>
                </tr>
                <?php 
				$omsettulipbnet20=0;
				$omsettulipbnet10=0;
				$omsetdealerbnet=0;
				foreach ($BnetTulip as $row26):
					     $omsettulipbnet20= $omsettulipbnet20 + $row26->TGroup20;
						 $omsettulipbnet10= $omsettulipbnet10 + $row26->TGroup10;
				endforeach;	
				foreach ($BnetDealer as $row27):
					     $omsetdealerbnet= $omsetdealerbnet + $row27->netDealer;
				endforeach;	 
				?>
                 <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Netto </td>
					
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbnet20))?'-':number_format($omsettulipbnet20)?></td>
                    <td colspan="3" align="center"><?php echo (empty($omsettulipbnet10))?'-':number_format($omsettulipbnet10)?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo (empty($omsetdealerbnet))?'-':number_format($omsetdealerbnet)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbnet))?'-':number_format(($omsetdealerbnet) * 1/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerbnet))?'-':number_format(($omsetdealerbnet * 1/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($omsetdealerbnet)){
						$NB20 = $NB20 + $omsettulipbnet20;
						$NB10 = $NB10 + $omsettulipbnet10;
						
						$BnetD = $omsetdealerbnet;
						$pphnetD = $pphnetD + ($omsetdealerbnet * 1/100) * 5/100;
						$BnsnetD = $BnsnetD + $omsetdealerbnet * 1 / 100;
						
						$har_Bnet = $har_Bnet + (($omsetdealerbnet) * 1/100) + (($omsetdealerbnet* 1/100) * 5/100);
					
						echo (empty($har_Bnet))?'-':number_format($har_Bnet);
					}
					
					?></td>
                </tr>
                <?php endforeach;?>
                <tr class="detail">
                	<td colspan="3">TOTAL FEE CABANG</td>
                    <td colspan="3" align="center"><?php echo number_format($regT20 + $calT20 + $tinT20 + $ifiT20 + 
														$ifoT20	+ $netT20 + $RB20 + $CB20 + $TB20 + $FH20 + $IF20 + $NB20);?></td>
                    <td colspan="3" align="center"><?php echo number_format($regT10 + $calT10 + $tinT10 + $ifiT10 + 
														$ifoT10	+ $netT10 + $RB10 + $CB10 + $TB10 + $FH10 + $IF10 + $NB10);?></td>
                    <td align="center">&nbsp;</td>
                    <td align="center"><?php echo number_format($regD + $hutD + $calD + $tinD + $ifiD + $ifoD + $netD + 
																$BregD + $BhutD + $BcalD + $BtinD + $BifiD + $BifoD + $BnetD
																)?></td>
                    <td align="center"><?php echo number_format(($regD * 1 / 100) + ($hutD * 1 / 100) + ($calD * 1/ 100) + ($tinD * 1/ 100)+ ($ifiD * 1/ 100)+ ($ifoD * 1/ 100)+ ($netD * 1/ 100) + $BnsregD + $BnscalD + $BnstinD + $BnsifiD + $BnsifoD + $BnsnetD)?></td>
                    <td align="center"><?php echo number_format((($regD * 1/100) * 5/100) + (($hutD * 1/100)*5/100) + (($calD * 1/100) * 5/ 100) + (($tinD * 1/100 )* 5/ 100)+ (($ifiD * 1/100) * 5/ 100)+ (($ifoD * 1/100) * 5/ 100)+ (($netD * 1/100) * 5/ 100) + $pphregD + $pphcalD + $pphtinD + $pphifiD + $pphifoD + $pphnetD);?></td>
 					<td align="center"><?php echo number_format($har_hut + $har_reg + $har_cal + $har_tin + $har_ifi+ $har_ifo+ $har_net
																+ $har_Bhut + $har_Breg + $har_Bcal + $har_Btin + $har_Bifi+ $har_Bifo+ $har_Bnet
																)?></td>
                </tr>
            </table>      
	  </td>
    </tr>
	            <tr>
                	<td align="center"><table width="800" align="center" class="detail">
                        <tr class="detail2">
                          <td width="229" colspan="4" align="center">DIBUAT OLEH</td>
                          <td width="229" colspan="4" align="center">DIPERIKSA OLEH</td>
                          <td width="229" colspan="4" align="center">DITERIMA OLEH</td>
                        </tr>
                        <tr>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="230" colspan="4" align="center">(....................)</td>
                          <td width="230" colspan="4" align="center">(....................)</td>
                          <td width="230" colspan="4" align="center">(....................)</td>
                        </tr>
                      </table></td>
  </tr>
</table>
</body>
</html>